package com.xtck.ha.fault.framework.utils;

import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

public class JsonUtil {
	/**
     * @Title: toJson
     * @Description: TODO Object转换json
     * @param obj
     * @return String
     * @throws
     */
    public static String toJson(Object obj) {
        GsonBuilder gb = new GsonBuilder();
        Gson gson = gb.create();
        return gson.toJson(obj);
    }
    /**
     * JSON 转 Object
     */
    public static <T> T jsonToObject(String pojo, Class<T> clazz) {
        return JSONObject.parseObject(pojo, clazz);
    }
}
